<template>
    <div>
        <div class="form-window">
            <div class="form-window-line"></div>
            <div class="form-window-txt">货物信息</div>
            <div class="form-window-btn">
                <el-button size="mini" @click="add()" type="text">添加货物信息
                </el-button>
            </div>
        </div>
        <div>
            <div class="form-form">
                <el-form label-position="left" label-width="140px" size="small">
                    <div style="border: 1px solid #E3E3E3;padding: 20px 16px 7px 16px;" v-for="(items, index) in goods"
                        :key="index">
                        <el-form-item label="货物名称">
                            <div style="display: flex;width: 100%;justify-content: space-between;align-items: center">
                                <el-input :disabled="edit" v-model="items.name" placeholder="请输入"
                                    class="form-input"></el-input>
                                <!-- <div class="form-window-btn">
                                    <el-button :disabled="edit" size="mini" type="text">历史信息
                                    </el-button>
                                    <el-button :disabled="edit" type="danger" icon="el-icon-delete"
                                        style="margin-left: 20px;"></el-button>
                                </div> -->
                            </div>
                        </el-form-item>
                        <el-form-item label="装载方式">
                            <div>
                                <el-select :disabled="edit" v-model="items.way_code" placeholder="请选择"
                                    class="form-input">
                                    <el-option v-for="item in selectList" @click.native="seleceChange(item, index)"
                                        :key="item.value" :label="item.label" :value="item.value">
                                    </el-option>
                                </el-select>
                            </div>
                        </el-form-item>
                    </div>
                </el-form>
                <div class="form-btn-box">
                    <el-button size="small" @click="updateInfoItem(10)">修改</el-button>
                    <el-button size="small" class="com-btn" @click="saveStorage(10)">保存
                    </el-button>
                </div>
            </div>

        </div>
    </div>
</template>
<script>
export default {
    props: {
        edit: { type: Boolean, default: false },
        goods: {}
    },
    data() {
        return {
            selectList: []
        }
    },
    mounted() {
        this.getData()
    },
    methods: {
        seleceChange(item, parentIndex) {

            this.goods[parentIndex].way = item.label
        },
        getData() {
            this.ajaxs("order/goodsType", {

                success: (res) => {
                    this.selectList = res.msg;

                },
            });
        },
        //保存
        saveStorage(index) {
            this.$emit('saveStorage', index)
        },
        //修改
        updateInfoItem(index) {
            this.$emit('updateInfoItem', index)
        },
        add() {
            let param = {
                name: "",
                way: "",
                way_code: ""
            }
            this.goods.push(param);
        }
    }
}


</script>
<style scoped>
@import "../../../assets/css/index/form.css";
</style>